Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix double clearing on autoclear #2666

Merged
merged 11 commits into from
Apr 4, 2024
Merged

Conversation

brindy
Copy link
Contributor

@brindy brindy commented Apr 3, 2024

Task/Issue URL: https://app.asana.com/0/414709148257752/1206731143449260/f
Tech Design URL:
CC:

Description:

Steps to test this PR:
Test standard fire button and fire proofing usage

  1. Open some tabs, set cookies (e.g. login to a site), use fire button ensure data is cleared
  2. Open some tabs, set cookies (e.g. login to a site), add to fire proofing, ensure data except fireproofed is cleared
  3. Open some tabs, set cookies (e.g. login to a site), terminate the app and reload, ensure tab loads as expected

Autoclear with Terminate

  1. Update settings to enable auto clear on terminate
  2. Open some tabs, set cookies (e.g. login to a site)
  3. Terminate the app
  4. Launch the app, ensure tabs and data are cleared

Autoclear with Terminate and Delay

  1. Update settings to enable auto clear on terminate with a delay
  2. Hack the code to return true for the selected delay in the shouldClearData function
  3. Background the app
  4. Use another app (e.g news) to launch a URL in DDG (either through default browser or by share extension)
  5. Ensure tabs and data are cleared

Autoclear with tabs only

  1. Repeat above tests but with tabs only selected in auto clear settings
  2. Ensure tabs are closed but data is retained

@brindy brindy requested a review from bwaresiak April 3, 2024 15:46
@brindy brindy marked this pull request as ready for review April 3, 2024 15:46
// but for now, ensure this happens in the right order by clearing data here too, if needed.
tabsModel = TabsModel(desktop: isPadDevice)
tabsModel.save()
previewsSource.removeAllPreviews()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to still remove previews?

@@ -998,6 +982,7 @@ class MainViewController: UIViewController {
currentTab?.progressWorker.progressBar = nil
currentTab?.chromeDelegate = nil

tab.delegate = self
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean by delaying the moment delegate is attached. The problem here is that before delegate is set, the view is apparently already loaded. The most likely place that could fail are the ones that use delegate methods which return a value like tabDidRequestSearchBarRect or tabCheckIfItsBeingCurrentlyPresented which could glitch the TabUI itself during its setup depending on the code flows (there could be other glitches too, but these are most likely).

We could investigate code paths to "fix" this now, but overall this is not a foolproof solution. I'm afraid that with TabManager being a Factory, a binding must occur as it was.

But looking at the code, I think it could remain as it was - just maybe don't pass self it through TabManager init as it's awkward for weak vars but explicitly invoke a manager.tabDelegate = self in MVC init.

weak var delegate: TabDelegate?
weak var delegate: TabDelegate? {
didSet {
assert(delegate != nil)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is getting triggered when using fire button, as prepareForDataClearing sets delegate to nil

Copy link
Collaborator

@bwaresiak bwaresiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from that assert: FIreproofing works. I could not reproduce startup issue either. Smoke tested fire button, tab creation, auto clear etc. Good job!

@brindy brindy merged commit cebfbf5 into main Apr 4, 2024
13 checks passed
@brindy brindy deleted the brindy/fix-double-clearing-on-autoclear branch April 4, 2024 19:06
jotaemepereira added a commit that referenced this pull request Apr 19, 2024
jotaemepereira added a commit that referenced this pull request Apr 19, 2024
Bunn added a commit that referenced this pull request Apr 19, 2024
This reverts commit cebfbf5.

# Conflicts:
#	DuckDuckGo/TabManager.swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants